<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!--********************************************************************
* 该示例需要引入
* Echarts (https://github.com/apache/echarts) 
* ol3Echarts (https://github.com/sakitam-fdd/ol3Echarts)
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_linesAirline"></title>
    <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
    <script type="text/javascript" include="echarts,ol3-echarts" src="../../dist/ol/include-ol.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, option, url = host + "/iserver/services/map-china/rest/maps/ChinaDark";
    var map = new ol.Map({
        target: 'map',
        // ol v7版本用法为ol.control.defaults.defaults； v6版本以下用法为ol.control.defaults
        controls: ol.control.defaults.defaults({attributionOptions: {collapsed: false}})
            .extend([new ol.supermap.control.Logo({ link: "https://iclient.supermap.io" })]),
        view: new ol.View({
            center: [0, 0],
            maxZoom: 18,
            zoom: 3,
            projection: 'EPSG:4326',
            multiWorld: true
        }),
        layers: [new ol.layer.Tile({
            source: new ol.source.TileSuperMapRest({
                url: url,
                prjCoordSys: {"epsgCode": 4326}
            }),
            projection: 'EPSG:4326'
        })]
    });
    var echartslayer = new EChartsLayer(null, {
        hideOnMoving: true,
        hideOnZooming: true
    });
    echartslayer.appendTo(map);
    $.get('../data/flights.json', function (data) {

        function getAirportCoord(idx) {
            return [data.airports[idx][3], data.airports[idx][4]];
        }

        var routes = data.routes.map(function (airline) {
            return [
                getAirportCoord(airline[1]),
                getAirportCoord(airline[2])
            ];
        });

        option = {
            title: {
                text: 'World Flights',
                left: 'center',
                textStyle: {
                    color: '#fff'
                }
            },
            tooltip: {
                formatter: function (param) {
                    var route = data.routes[param.dataIndex];
                    return data.airports[route[1]][1] + ' > ' + data.airports[route[2]][1];
                }
            },

            series: [{
                type: 'lines',
                data: routes,
                large: true,
                largeThreshold: 100,
                lineStyle: {
                    normal: {
                        opacity: 0.05,
                        width: 0.5,
                        curveness: 0.3
                    }
                },
                // 设置混合模式为叠加
                blendMode: 'lighter'
            }]
        };
        echartslayer.setChartOptions(option);
    });
</script>
</body>
</html>